<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * CodeIgniter
 *
 * An open source application development framework for PHP 5.1.6 or newer
 *
 * @package		CodeIgniter
 * @author		ExpressionEngine Dev Team
 * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc.
 * @license		http://codeigniter.com/user_guide/license.html
 * @link		http://codeigniter.com
 * @since		Version 1.0
 * @filesource
 */

// ------------------------------------------------------------------------

/**
 * CodeIgniter Application Controller Class
 *
 * This class object is the super class that every library in
 * CodeIgniter will be assigned to.
 *
 * @package		CodeIgniter
 * @subpackage	Libraries
 * @category	Libraries
 * @author		ExpressionEngine Dev Team
 * @link		http://codeigniter.com/user_guide/general/controllers.html
 */
class CI_Controller {


	private static $instance;

	/**
	 * Constructor
	 */
	public function __construct()
	{
		self::$instance =& $this;
		
		// Assign all the class objects that were instantiated by the
		// bootstrap file (CodeIgniter.php) to local class variables
		// so that CI can run as one big super object.
		foreach (is_loaded() as $var => $class)
		{
			$this->$var =& load_class($class);
		}

		$this->load =& load_class('Loader', 'core');

		$this->load->_base_classes =& is_loaded();

		$this->load->_ci_autoloader();

		//julio arredondo: inicia la session
                $this->load->library('session');
                
                log_message('debug', "Controller Class Initialized");



	}

	public static function &get_instance()
	{
		return self::$instance;
	}

        /*
         * Adhoc implementation for hds_scrum
         * @author: julio arredondo
         */
        protected $response;
        protected $gui_data;

        protected function json_response($exito, $mensaje, $codigo = null) {
            $this->create_reponse($exito, $mensaje, $codigo);
            $this->load->view("json_response", array("response" => $this->response));
        }

        protected function create_reponse($exito, $mensaje, $codigo = null) {
            $this->response = array();
            $this->response['exito'] = $exito;
            $this->response['mensaje'] = $mensaje;
            if ($codigo != null) {
                $this->response['codigo'] = $codigo;
            }
        }


        protected function add_data_response($object, $alias = null){
             if ($alias == null) {
                $this->repsonse['data'] = $object;
            } else {
                $this->repsonse['data'][$alias] = $object;
            }
        }

        protected function gui_data($object, $alias = null) {
            if ($alias == null) {
                $this->gui_data = array("data" => $object);
            } else {
                $this->gui_data["data"][$alias] = $object;
            }
        }

        protected function load_json_view($view, $data){
            $this->load->view("json_data_view", array("json_data" => $data));
            $this->load->view($view);
        }

        protected function is_login(){
            return $this->session->userdata('is_login');
        }

        protected function get_login_data(){
            return array("id_usuario" => $this->session->userdata('id_usuario'),
                "id_proyecto" => $this->session->userdata('d_proyecto'),
                "perfil" => $this->session->userdata('perfil'));
        }
}
// END Controller class

/* End of file Controller.php */
/* Location: ./system/core/Controller.php */